package com.hh.service.service.impl;

import com.hh.common.exception.HhException;
import com.hh.common.model.order.StoreOrder;
import com.hh.common.utils.RedisUtil;
import com.hh.service.service.NewOrderService;
import com.hh.service.service.OrderPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MaintenanceService {

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private OrderPayService orderPayService;

    @Autowired
    private NewOrderService newOrderService;

    public Boolean systemMaintenance(Integer sysType,String code, Integer type) {
        if(!"K7319dl$B83afc832".equals(code)){
            throw new HhException("操作码错误");
        }
        if(sysType == 1){
            if(type == 1){
                redisUtil.set("APP_IS_CLOSE",1);
            }else {
                redisUtil.delete("APP_IS_CLOSE");
            }
        }else {
            if(type == 1){
                redisUtil.set("SYSTEM_BACKSTAGE_IS_SHUTDOWN",1);
            }else {
                redisUtil.delete("SYSTEM_BACKSTAGE_IS_SHUTDOWN");
            }
        }

        return true;
    }

    public Boolean test01(String orderId) {
        StoreOrder order = newOrderService.getByOderId(orderId);
        boolean result = orderPayService.paySuccess(order);


        return Boolean.TRUE;
    }
}
